<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
	.error {
	  color: red;
	 }
</style>
</head>
<body>
 
<c:if test="${statusExists}">
	<td><c:out value="Status alreadry exits!"/></td>
</c:if>

<form:form modelAttribute="orderStatus" method="POST" action="">
<form:errors path="" cssClass="error"/>
<form:hidden path="orderStatusId" />
<form:hidden path="order.orderId" />
 <table>
  <tr>
   <td><form:label path="orderStatusName.orderStatusNameId">status:</form:label></td>
   <td><form:select path="orderStatusName.orderStatusNameId" items="${statuses}" multiple="false" /></td>
   <td><form:errors path="orderStatusName.orderStatusNameId" cssClass="error"/></td>
  </tr>
  
  <tr>
   <td><form:label path="place">place:</form:label></td>
   <td><form:input path="place"/></td>
   <td><form:errors path="place" cssClass="error"/></td>
  </tr>
  
  
  <tr>
   <td><form:label path="statusTime">time:</form:label></td>
   <fmt:formatDate value="${orderStatus.statusTime}" var="dateString" pattern="dd-MM-yyyy HH:mm" />
   <td><form:input path="statusTime" value="${dateString}" /></td>
   <td><form:errors path="statusTime" cssClass="error"/></td>
  </tr>


 </table>
 <table>
 <tr>
 <c:if test="${!add}">
 	<td><input type="submit"  name="action"  value="Save" /></td>
</c:if>
 <c:if test="${add}">
 	<td><input type="submit"  name="action"  value="Add" /></td>
</c:if>
<c:url var="backUrl" value="/admin/order/status" >
 		<c:param name="orderId" value="${orderStatus.order.orderId}" />
</c:url>
<td> <a href='<c:out value="${backUrl}"/>'>back</a> </td>
</tr>
</table>
</form:form>
</body>
</html>